import 'package:bxultimate/app/theme/app_theme.dart';
import 'package:bxultimate/app/theme/gaps.dart';
import 'package:bxultimate/resources/assets.dart';
import 'package:bxultimate/widgets/mk_card_container.dart';
import 'package:bxultimate/widgets/mk_list_cell_item.dart';
import 'package:bxultimate/widgets/mk_load_image.dart';
import 'package:bxultimate/widgets/mk_page.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';

import 'controller.dart';

class OrganizationContactListPage extends StatefulWidget {
  const OrganizationContactListPage({Key? key}) : super(key: key);

  @override
  State<OrganizationContactListPage> createState() =>
      _OrganizationContactListPageState();
}

class _OrganizationContactListPageState
    extends State<OrganizationContactListPage> {
  final controller = Get.find<OrganizationContactListController>();
  final state = Get.find<OrganizationContactListController>().state;

  @override
  Widget build(BuildContext context) {
    return MkPage(
        child: Scaffold(
      backgroundColor: Colors.transparent,
      appBar: TDNavBar(
        backgroundColor: Colors.transparent,
        title: '通讯录',
      ),
      body: SingleChildScrollView(
        child: _buildBody(),
      ),
    ));
  }

  _buildBody() {
    return Padding(
        padding: EdgeInsets.symmetric(horizontal: AppTheme.iDefaultPadding),
        child: Column(
          children: [
            ClipRRect(
              borderRadius: BorderRadius.circular(8),
              child: TDSearchBar(
                controller: controller.searchEditController,
                placeHolder: '请输入',
              ),
            ),
            Gaps.vGap8,
            _buildList(),
          ],
        ));
  }

  _buildList() {
    return MkCardContainer(
      padding: EdgeInsets.symmetric(horizontal: AppTheme.iDefaultPadding / 2),
      margin: EdgeInsets.all(0),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          MkListCellItem(
            value: '',
            textIcon: Row(
              children: [
                MkLoadImage(
                  Assets.imagesIcon,
                  width: 44,
                ),
                Gaps.hGap12,
                Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Text(
                      '陈坤',
                      style: TextStyle(fontSize: 14),
                    ),
                    Gaps.vGap4,
                    TDTag(
                      '管理员',
                      theme: TDTagTheme.primary,
                      size: TDTagSize.small,
                      isOutline: true,
                    ),
                  ],
                )
              ],
            ),
            height: 60,
            ext: Text('13333333333'),
            rightIcon: Icon(Icons.phone, color: Colors.blue),
            press: () {},
          ),

          MkListCellItem(
            value: '',
            textIcon: Row(
              children: [
                MkLoadImage(
                  Assets.imagesIcon,
                  width: 44,
                ),
                Gaps.hGap12,
                Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Text(
                      '陈坤',
                      style: TextStyle(fontSize: 14),
                    ),
                    Gaps.vGap4,

                  ],
                )
              ],
            ),
            height: 60,
            ext: Text('13333333333'),
            rightIcon: Icon(Icons.phone, color: Colors.blue),
            press: () {},
          ),
        ],
      ),
    );
  }

  @override
  void dispose() {
    Get.delete<OrganizationContactListController>();
    super.dispose();
  }
}
